<?php
if(isset($_REQUEST['offset'])){
	$v_offset=$_REQUEST['offset'];
}
else
	$v_offset=1;
	
$v_limit = CONST_NUMBER_OF_QA_PER_PAGE;
if(isset($_REQUEST['page'])){
	$page=$_REQUEST['page'];
}
else
	$page=1;
/////////////////////////////////////////////////////////////////////////
if(isset($_REQUEST['start_date'])){
	$v_date_start = trim($_REQUEST['start_date']);
	$v_date_start_sp=_ddmmyyyy_to_yyyymmdd($v_date_start);
} else
	$v_date_start = '';

if(isset($_REQUEST['end_date'])){
	$v_date_end = trim($_REQUEST['end_date']);
	$v_date_end_sp=_ddmmyyyy_to_yyyymmdd($v_date_end);
} else
	$v_date_end = '';


if(isset($_REQUEST['agency_id'])){
	$v_agency_id = intval($_REQUEST['agency_id']);	
} else
	$v_agency_id = 0;

$v_cate_id = 0;
if(isset($_REQUEST['cate_id'])){
	$v_cate_id = intval(trim($_REQUEST['cate_id']));
}

$v_filter = '';
if(isset($_REQUEST['txt_filter_value'])){
	$v_filter = $_REQUEST['txt_filter_value'];
}

if(isset($_REQUEST['method'])){	
	$v_method = $_REQUEST['method'];
}else
	$v_method = 1;

$v_status = 2;
if(_is_sqlserver()){
	$sql = "Exec Onegate_QAGetAllBYCONDITIONS " ;
	$sql = $sql.$v_status.",";
	$sql = $sql.$v_method.",";
	$sql = $sql."'".$v_filter."',";
	$sql = $sql.$v_agency_id.",";
	$sql = $sql.$v_cate_id.",";
	$sql = $sql."'".$v_date_start_sp."',";
	$sql = $sql."'".$v_date_end_sp."'";
	//echo $sql; exit;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$arr_result = $ado_conn->GetAll($sql); 
	$v_total_qa_count=sizeof($arr_result);

	$pager  = Pager::getPagerData($v_total_qa_count, $v_limit, $page);
	$page   = $pager->page;
  	$offset = $pager->offset +1; 
  	$limit = $pager->limit;
	
	$cmd = @mssql_init("Onegate_QAGetBYCONDITIONS", $conn);
	@mssql_bind($cmd, "@p_status", $v_status, SQLINT4);
	@mssql_bind($cmd, "@p_method", $v_method, SQLINT4);
	@mssql_bind($cmd, "@p_filter", $v_filter, SQLVARCHAR);
	@mssql_bind($cmd, "@p_agency_id", $v_agency_id, SQLINT4);
	@mssql_bind($cmd, "@p_cate_id", $v_cate_id, SQLINT4);
	@mssql_bind($cmd, "@p_date_start", $v_date_start_sp, SQLVARCHAR);
	@mssql_bind($cmd, "@p_date_end", $v_date_end_sp, SQLVARCHAR);
	@mssql_bind($cmd,"@offset", $offset,SQLINT4);	
	@mssql_bind($cmd,"@limit",$limit,SQLINT4);	
	$result = @mssql_execute($cmd);
	$arr_qa = _get_row_to_array($result);
	$v_num_qa=sizeof($arr_qa);	
	@mssql_free_result($result);
	
}?>